﻿@model XPressify.Models.RelationshipFamilyEditModel
@using XPressify.Data.Helpers
@using XPressify.Controllers
@using Omu.Awesome.Core;
@using Omu.Awesome.Mvc.Helpers;

@{
    ViewBag.Title = "Family relationship ";
}


<script type="text/javascript">
    
    var isValid = true;
    $("form").submit(function () {
        var selectedUserId = $('#SelectedUser').val();
        if (selectedUserId == '00000000-0000-0000-0000-000000000000') {
            isValid = false;
        }
        else {
            isValid = true;
        }
        return isValid;
    });
        
</script>


<div>
    @(Html.MakePopupForm<ProfileController>(o => o.RelationshipFamilyDelete(Model.CurrentUserId), title: "Delete family relationship", height: 600, width: 900, okText: "Delete", resizable: false, refreshOnSuccess: true))
    @(Html.PopupFormActionLink<ProfileController>(o => o.RelationshipFamilyDelete(Model.CurrentUserId), "Delete family relationship", new { @class = "nobtn" }))
</div>

    @using (Html.BeginForm("RelationshipFamilyEdit", "Profile", FormMethod.Post, new { id = "mySpecialForm" }))
    {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend style="font-size:x-large;color:#222">Family relationship</legend>
        
        <br />

        <div class="editor-label">
            @Html.LabelFor(model => model.RelationType)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.RelationType, new List<SelectListItem> { new SelectListItem { Text = "Child", Value = RelationshipType.ChildOf.ToString() }, new SelectListItem { Text = "Grandchild", Value = RelationshipType.GrandchildOf.ToString() }, new SelectListItem { Text = "Nephew/Niece", Value = RelationshipType.SiblingchildOf.ToString() } , new SelectListItem { Text = "Parent", Value = (RelationshipType.ChildOf * (-1)).ToString() }, new SelectListItem { Text = "Grandparent", Value = (RelationshipType.GrandchildOf * (-1)).ToString() }, new SelectListItem { Text = "Uncle/Aunt", Value = (RelationshipType.SiblingchildOf * (-1)).ToString() }, new SelectListItem { Text = "Cousin", Value = RelationshipType.CousinOf.ToString() }, new SelectListItem { Text = "Sibling", Value = RelationshipType.SiblingOf.ToString() } })
        </div>



        <label>Select user:</label>
        <input type="hidden" value="@Model.CurrentUserId" name="myCurrentUserId" id="myCurrentUserId" />
        <ul class='ae-lookup-list'>
            @Html.LookupFor(o => o.SelectedUser, controller: "FriendsLookup", multiselect: false, clearButton: true, title: "Select friend", data: new Dictionary<string, string> { { "myCurrentUserId", "currentUserIdString" } })
            @Html.ValidationMessageFor(model => model.SelectedUser)
        </ul>

        <br /> <br /> <br />

        <p>
            <input type="submit" value="Save" id="mySpecialSubmitBtn" onclick="Begin"/>
        </p>
    </fieldset>
}


